/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.web.servlet;

import com.web.daoimpl.CourseDaoImpl;
import com.web.entity.Course;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author liqianru
 */
@WebServlet("/getCoursebykeyword")
public class Admin_getCourseBykeyword  extends HttpServlet{

    CourseDaoImpl service= new CourseDaoImpl();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
            HttpSession session=req.getSession();
            List<Course> list=new ArrayList<>();
            String action=req.getParameter("action");
            if(action.equals("searchC")){
            
            String keyword=req.getParameter("keywordforC");
            list=service.getBykeyword(keyword);
            session.setAttribute("allCourse", list);
            System.out.println(keyword);
           
           req.getRequestDispatcher("/admin_Course.jsp").forward(req, resp);
            }
            if(action.equals("searchS")){
                String keyword_s=req.getParameter("keyword");
                list=service.getsBykeyword(keyword_s);
                session.setAttribute("allCourse", list);
                req.getRequestDispatcher("/admin_schedule.jsp").forward(req, resp);
            }
    }
    
}
